package com.example.simin_manage.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: panpan
 * @time: 2025/9/12
 */


/**
 * 通用返回类
 */
public class R extends HashMap<String, Object> {

    public static R success() {
        R r = new R();
        r.put("success", true);
        return r;
    }

    public static R success(Object data) {
        R r = new R();
        r.put("success", true);
        r.put("data", data);
        return r;
    }

    public static R error(String msg) {
        R r = new R();
        r.put("success", false);
        r.put("message", msg);
        return r;
    }

    public R put(String key, Object value) {
        super.put(key, value);
        return this;
    }
    public static R fail(String msg) {
        return error(msg);
    }
    public static R ok(String key, Object value) {
        R r = new R();
        r.put("success", true);
        r.put(key, value);
        return r;
    }



}

